/*******************************************************************************
 Configuration Information:
 Repository: Integrity Source
 Name      : $RCSfile: AR_CD_ActvnMgr.c $
 Version   : $Revision: 1.12 $
 Author    : $Author: Jack Jin (JinC5) $
 Date      : $Date: 2018/09/18 19:53:59IST $
 Location  : $ProjectName: /Steering/Projects/Geely/CMA_DP/PR48756_LVS_ENG_APP_Geely_CMA_EPS_DP_SYS_HRoom_AP/30_Software/3040_Design/S2-Application/01-Development/V00-Mainline/04-Components/ActiveReturn_Ear/Source/project.pj $
********************************************************************************

   ZF Friedrichshafen AG owns the copyright in this document and associated
   documents and all rights are reserved.  These documents must
   not be used for any purpose other than that for which they
   are supplied and must not be copied in whole or in part or
   disclosed to others without prior written consent of ZF Friedrichshafen AG.
   Any copy of this drawing or document made by any method
   must also include a copy of this legend.

   (C) ZF Friedrichshafen AG 2018

*******************************************************************************/
/**************************************************************************************************\
 *** 
 *** Simulink model       : AR_CD_ActvnMgr_tl
 *** TargetLink subsystem : AR_CD_ActvnMgr_tl
 *** Codefile             : AR_CD_ActvnMgr.c
 ***
 *** Generated by TargetLink, the dSPACE production quality code generator
 *** Model version: 1.621
 *** Generation date: 2018-09-18 14:55:00
 ***
 *** CODE GENERATOR OPTIONS:
 *** Code generation mode                     : AUTOSAR
 *** AUTOSAR version                          : 4.2.2
 *** Compiler                                 : <unknown>
 *** Target                                   : Generic
 *** ANSI-C compatible code                   : yes
 *** Code Optimization                        : enabled
 *** Constant style                           : decimal
 *** Clean code option                        : enabled
 *** Logging mode                             : Do not log anything
 *** Code Coverage                            : disabled
 *** Generate empty conditional branches      : disabled
 *** Loop unroll threshold                    : 5
 *** Shift mode                               : automatic
 *** Handle unscaled SF expr. with TL type    : enabled
 *** Assignment of conditions                 : AllBooleanOutputs 
 *** Scope reduction only to function level   : disabled
 *** Exploit ranges if not erasable           : disabled
 *** Exploit Compute Through Overflow         : never
 *** Linker sections                          : enabled
 *** Enable Assembler                         : disabled
 *** Variable name length                     : unlimited
 *** Use global bitfields                     : disabled
 *** Stateflow: use of bitfields              : enabled
 *** State activity encoding limit            : 8
 *** Omit zero inits in restart function      : disabled
 *** Share functions between TL subsystems    : disabled
 *** Generate 64bit functions                 : disabled
 *** Inlining Threshold                       : 6
 *** Line break limit                         : 100
 *** Target optimized boolean data type       : enabled
 *** Keep saturation elements                 : disabled
 *** Extended variable sharing                : disabled
 *** Extended lifetime optimization           : enabled
 *** Style definition file                    : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\Con
 ***                                            fig\codegen\cconfig.xml
 *** Root style sheet                         : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\XML
 ***                                            \CodeGen\Stylesheets\TL_CSourceCodeSS.xsl
 ***
 *** SUBSYS                   CORRESPONDING SIMULINK SUBSYSTEM
 *** SAR_CD_041               AR_CD_ActvnMgr_tl
 *** SAR_CD_042               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr
 *** SAR_CD_043               AR_CD_ActvnMgr_tl/DocFunction
 *** SAR_CD_044               AR_CD_ActvnMgr_tl/IncludeAppHeader
 *** SAR_CD_061               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl
 *** SAR_CD_071               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl
 *** SAR_CD_081               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl
 *** SAR_CD_062               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain
 *** SAR_CD_063               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/DocFuncti
 ***                          on
 *** SAR_CD_064               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/SaturationDynamic
 *** SAR_CD_065               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/ZFDivA_fabs
 *** SAR_CD_066               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/ZFDivA_fabs1
 *** SAR_CD_067               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/ZFDivA_fabs3
 *** SAR_CD_068               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/ZFDivA_fabs4
 *** SAR_CD_069               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/SaturationDynamic/input
 *** SAR_CD_0610              AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/SaturationDynamic/max
 *** SAR_CD_0611              AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Act
 ***                          vnMgr_ActvnGain/SaturationDynamic/min
 *** SAR_CD_0612              AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/DocFuncti
 ***                          on/EmptySubsystem
 *** SAR_CD_072               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_Act
 ***                          vnMgr_InpSigVer
 *** SAR_CD_073               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/DocFuncti
 ***                          on
 *** SAR_CD_074               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/DocFuncti
 ***                          on/EmptySubsystem
 *** SAR_CD_082               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_Actvn
 ***                          Mgr_RampFac
 *** SAR_CD_083               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/DocFunction
 *** SAR_CD_084               AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/DocFunction
 ***                          /EmptySubsystem
 *** SAR_CD_045               AR_CD_ActvnMgr_tl/DocFunction/EmptySubsystem
 *** 
 *** SUBSYS                   CORRESPONDING MODEL BLOCK (REFERENCED MODEL)
 *** 
 *** SF-NODE   CORRESPONDING STATEFLOW NODE                           DESCRIPTION
 *** CAR_CD_04
 *** 0         AR_CD_ActvnMgr_InpSigVer_tl                            
 *** CAR_CD_04
 *** 1         AR_CD_ActvnMgr_RampFac_tl                              
 *** CAR_CD_07
 *** 1         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSig
 ***           Ver_tl/AR_CD_ActvnMgr_InpSigVer/RackAbsPosn Check      
 *** CAR_CD_08
 *** 1         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 ***           c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine     
 *** CAR_CD_08
 *** 2         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 *** c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.Ear
 ***           Disabled                                               
 *** CAR_CD_08
 *** 3         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 *** c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.Ear
 ***           WaitingForArbitration                                  
 *** CAR_CD_08
 *** 4         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 *** c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.Ear
 ***           RampDown                                               
 *** CAR_CD_08
 *** 5         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 *** c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.Ear
 ***           RampUp                                                 
 *** CAR_CD_08
 *** 6         AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
 *** c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.Ear
 ***           Enabled                                                
 *** 
 *** TargetLink version      : 4.2p2 from 27-Nov-2017
 *** Code generator version  : Build Id 4.2.0.33 from 2017-11-28 14:39:24

\**************************************************************************************************/

#ifndef AR_CD_ACTVNMGR_C
#define AR_CD_ACTVNMGR_C

/*----------------------------------------------------------------------------*\
  DEFINES (OPT)
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INCLUDES
\*----------------------------------------------------------------------------*/

#include "Rte_ActiveReturnSwc.h"
#include "AR_CD_RackVDmd.h"
#include "AR_CD_ActvnMgr.h"
#include "ActiveReturnSwc_Library.h"

/*----------------------------------------------------------------------------*\
  ENUMS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  DEFINES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  TYPEDEFS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  VARIABLES
\*----------------------------------------------------------------------------*/

/******************************************************************************\
   VC_STRUCT_InitAtDef: Used for global struct variables. Initialised at definition. Creates access 
   functions (get and set). | Width: N.A.
\******************************************************************************/
struct tAR_CD_ActvnMgr_tag var_AR_CD_ActvnMgr = {
   0.F, /* EarActvn */
   0.F, /* EarRampFac */
   0, /* EarARBActvnReq */
   0.F /* EarRackPosnCtrlErrSign */
};

struct tAR_CD_ActvnMgr_ActvnGain_tag var_AR_CD_ActvnMgr_ActvnGain = {
   0, /* EarDampgRqrd */
   0, /* EarUnredAcv */
   0.F, /* EarActvnUnfild */
   0.F /* EarActvn */
};

struct tAR_CD_ActvnMgr_InpSigVer_tag var_AR_CD_ActvnMgr_InpSigVer = {
   0, /* RackAbsPosnQfSts */
   0, /* RackVQfSts */
   0, /* FildVehSpdQfSts */
   0, /* ColTqQfSts */
   0 /* EarInpSigVer */
};

struct tAR_CD_ActvnMgr_RampFac_tag var_AR_CD_ActvnMgr_RampFac = {
   0, /* EarRampUp */
   0, /* EarEnabled */
   0, /* EarRampDown */
   0, /* EarWaitingForArbitration */
   0 /* EarDisabled */
};

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    32
\******************************************************************************/
static Float32 CAR_CD_081_ear_ramp_fac_unlim = 0.F;

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    16
\******************************************************************************/
static sint16 CAR_CD_081_ear_delay_count = 0;

/******************************************************************************\
   SFStaticGlobalInit: Default storage class for global static variables with initial value | Width:
    8
\******************************************************************************/
static Boolean CAR_CD_081_EarARBActvnReq = 0;
static Boolean CAR_CD_081_EarDisabled = 0;

/* Custom code: AR_CD_ActvnMgr_tl/IncludeAppHeader/CC_AppHeaderInclude << declaration code >> */
#include "Rte_ActiveReturnSwc.h"
/*----------------------------------------------------------------------------*\
  PARAMETERIZED MACROS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION PROTOTYPES
\*----------------------------------------------------------------------------*/

/******************************************************************************\
   StaticSFEntry: Default function class for static stateflow entry functions
\******************************************************************************/
static void CAR_CD_082_EarDisabled_en(void);

/*----------------------------------------------------------------------------*\
  INLINE FUNCTIONS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      AR_CD_ActvnMgr
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      mmPerSec           ArRackVDmdRaw       
 ***      mmPerSec           RackVCmbnd          
 ***      tArbitrationState  ARBArGatewySt       
 ***      tQualityFactor     RackAbsPosnQF       
 ***      tQualityFactor     RackVQF             
 ***      tQualityFactor     FildVehSpdQF        
 ***      tQualityFactor     ColTqQF             
 ***      Float32            EarActvnUnfild      
 ***      Float32            EarActvnRedUnfild   
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
void AR_CD_ActvnMgr(mmPerSec ArRackVDmdRaw, mmPerSec RackVCmbnd, tArbitrationState ARBArGatewySt,
  tQualityFactor RackAbsPosnQF, tQualityFactor RackVQF, tQualityFactor FildVehSpdQF, tQualityFactor
  ColTqQF, Float32 EarActvnUnfild, Float32 EarActvnRedUnfild)
{
   /* AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/Function-Call Generator
      call of function: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/RackVQF
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/SteeringPositionLowerQF
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/FildVehSpdQF
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/ColTqQF */
   AR_CD_ActvnMgr_InpSigVer(RackAbsPosnQF, RackVQF, FildVehSpdQF, ColTqQF);

   /* update(s) for inport AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/EarRackPosnC
      trlErrSign */
   var_AR_CD_RackVDmd.EarRackPosnCtrlErrSign = (sint16) var_AR_CD_ActvnMgr.EarRackPosnCtrlErrSign;

   /* call of function: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/RackVCmbnd
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/EarRackVDmdRaw
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/EarActvnUnfild
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/EarActvnRedUnfild */
   AR_CD_ActvnMgr_ActvnGain(EarActvnUnfild, EarActvnRedUnfild, RackVCmbnd, ArRackVDmdRaw);

   /* call of function: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl
      # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/EarArbnSt */
   AR_CD_ActvnMgr_RampFac(ARBArGatewySt, var_AR_CD_ActvnMgr_InpSigVer.EarInpSigVer);

   /* TargetLink outport: AR_CD_ActvnMgr_tl/EarActvn */
   var_AR_CD_ActvnMgr.EarActvn = var_AR_CD_ActvnMgr_ActvnGain.EarActvn;
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      AR_CD_ActvnMgr_ActvnGain
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      Float32            EarActvnUnfild      
 ***      Float32            EarActvnRedUnfild   
 ***      mmPerSec           RackVCmbnd          
 ***      mmPerSec           ArRackVDmdRaw       
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
void AR_CD_ActvnMgr_ActvnGain(Float32 EarActvnUnfild, Float32 EarActvnRedUnfild, mmPerSec
  RackVCmbnd, mmPerSec ArRackVDmdRaw)
{
   /* SLLocal: Default storage class for local variables | Width: 32 */
   Float32 SAR_CD_062_Add;
   Float32 SAR_CD_062_Add1;
   Float32 SAR_CD_062_Add2;
   Float32 SAR_CD_062_EAR_ACTVN_SWT_RATE_LIM_MAP;
   float32 SAR_CD_062_Product1;
   float32 SAR_CD_065_Switch;
   float32 SAR_CD_066_Switch;
   float32 SAR_CD_067_Switch;
   float32 SAR_CD_068_Switch;

   /* SLLocal: Default storage class for local variables | Width: 16 */
   sint16 SAR_CD_062_Sign_RackV;
   sint16 SAR_CD_062_Sign_RackVDmd;

   /* SLLocal: Default storage class for local variables | Width: 8 */
   boolean SAR_CD_062_Relational_Operator8;
   boolean SAR_CD_062_Relational_Operator9;

   /* SLLocalInit: Default storage class for local variables with init value | Width: 32 */
   Float32 SAR_CD_064_Merge_Y;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 32
    */
   static Float32 X_SAR_CD_062_Unit_Delay1 = 0.F;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 16
    */
   static sint16 X_SAR_CD_062_Unit_Delay2 = 0;

   /* SLStaticLocalInit: Default storage class for static local variables with initvalue | Width: 8
    */
   static Boolean X_SAR_CD_062_Unit_Delay3 = 0;

   /* Sign: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Si
      gn RackV */
   if (RackVCmbnd < 0.F) {
      SAR_CD_062_Sign_RackV = -1;
   }
   else {
      SAR_CD_062_Sign_RackV = (sint16) (RackVCmbnd > 0.F);
   }

   /* Product: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain
      /Product1 */
   SAR_CD_062_Product1 = ArRackVDmdRaw * ((float32) var_AR_CD_RackVDmd.EarRackPosnCtrlErrSign);

   /* Sign: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Si
      gn RackVDmd */
   if (SAR_CD_062_Product1 < 0.F) {
      SAR_CD_062_Sign_RackVDmd = -1;
   }
   else {
      SAR_CD_062_Sign_RackVDmd = (sint16) (SAR_CD_062_Product1 > 0.F);
   }

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      ZFDivA_fabs3/Switch
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/ZFDivA_f
      abs3/Switch: Omitted comparison with constant.
      # combined # Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/ZFDivA_fabs3/Relational Operator */
   if (RackVCmbnd < 0.F) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs3/Switch
         # combined # Gain: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
         Mgr_ActvnGain/ZFDivA_fabs3/Gain */
      SAR_CD_067_Switch = RackVCmbnd * -1.F;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs3/Switch */
      SAR_CD_067_Switch = RackVCmbnd;
   }

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      ZFDivA_fabs1/Switch
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/ZFDivA_f
      abs1/Switch: Omitted comparison with constant.
      # combined # Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/ZFDivA_fabs1/Relational Operator */
   if (SAR_CD_062_Product1 < 0.F) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs1/Switch
         # combined # Gain: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
         Mgr_ActvnGain/ZFDivA_fabs1/Gain */
      SAR_CD_066_Switch = SAR_CD_062_Product1 * -1.F;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs1/Switch */
      SAR_CD_066_Switch = SAR_CD_062_Product1;
   }

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnG
      ain/Damp  */
   var_AR_CD_ActvnMgr_ActvnGain.EarDampgRqrd = SAR_CD_067_Switch >= SAR_CD_066_Switch;

   /* Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain
      /Logical Operator2 */
   var_AR_CD_ActvnMgr_ActvnGain.EarUnredAcv = ((SAR_CD_062_Sign_RackV != SAR_CD_062_Sign_RackVDmd)
    && (SAR_CD_062_Product1 != ZERO_CONST)) || (!(var_AR_CD_ActvnMgr_ActvnGain.EarDampgRqrd));

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      Switch
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Switch: 
      Omitted comparison with constant. */
   if (var_AR_CD_ActvnMgr_ActvnGain.EarUnredAcv) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/Switch */
      var_AR_CD_ActvnMgr_ActvnGain.EarActvnUnfild = EarActvnUnfild;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/Switch */
      var_AR_CD_ActvnMgr_ActvnGain.EarActvnUnfild = EarActvnRedUnfild;
   }

   /* Sum: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Add
      2 */
   SAR_CD_062_Add2 = var_AR_CD_ActvnMgr_ActvnGain.EarActvnUnfild - X_SAR_CD_062_Unit_Delay1;

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      ZFDivA_fabs/Switch
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/ZFDivA_f
      abs/Switch: Omitted comparison with constant.
      # combined # Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/ZFDivA_fabs/Relational Operator */
   if (RackVCmbnd < 0.F) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs/Switch
         # combined # Gain: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
         Mgr_ActvnGain/ZFDivA_fabs/Gain */
      SAR_CD_065_Switch = RackVCmbnd * -1.F;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs/Switch */
      SAR_CD_065_Switch = RackVCmbnd;
   }

   /* TableLookup: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_Actvn
      Gain/EAR_ACTVN_SWT_RATE_LIM_MAP */
   SAR_CD_062_EAR_ACTVN_SWT_RATE_LIM_MAP = Tab1DnMS3I2T3126_AR_CD_04(6, (const float32 *)
    &(Rte_CData_EAR_ACTVN_RACK_V_BRKPTS()[0]), (const float32 *)
    &(Rte_CData_EAR_ACTVN_SWT_RATE_LIM_MAP()[0]), SAR_CD_065_Switch);
   if (SAR_CD_062_Add2 > SAR_CD_062_EAR_ACTVN_SWT_RATE_LIM_MAP) {
      /* Reference of merge block: Merge Y AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain
         _tl/AR_CD_ActvnMgr_ActvnGain/Saturation Dynamic/Merge Y
         update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Actvn
         Gain_tl/AR_CD_ActvnMgr_ActvnGain/Saturation
         Dynamic/max/Y
         # combined # Outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
         tvnMgr_ActvnGain/Saturation Dynamic/max/Y */
      SAR_CD_064_Merge_Y = SAR_CD_062_EAR_ACTVN_SWT_RATE_LIM_MAP;
   }
   else {
      /* SLLocal: Default storage class for local variables | Width: 32 */
      Float32 SAR_CD_062_Gain;

      /* Gain: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain
         /Gain */
      SAR_CD_062_Gain = SAR_CD_062_EAR_ACTVN_SWT_RATE_LIM_MAP * -1.F;
      if (SAR_CD_062_Add2 < SAR_CD_062_Gain) {
         /* Reference of merge block: Merge Y AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnG
            ain_tl/AR_CD_ActvnMgr_ActvnGain/Saturation Dynamic/Merge Y
            update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Ac
            tvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Saturation
            Dynamic/min/Y
            # combined # Outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD
            _ActvnMgr_ActvnGain/Saturation Dynamic/min/Y */
         SAR_CD_064_Merge_Y = SAR_CD_062_Gain;
      }
      else {
         /* Reference of merge block: Merge Y AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnG
            ain_tl/AR_CD_ActvnMgr_ActvnGain/Saturation Dynamic/Merge Y
            update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Ac
            tvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Saturation
            Dynamic/input/Y
            # combined # Outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD
            _ActvnMgr_ActvnGain/Saturation Dynamic/input/Y */
         SAR_CD_064_Merge_Y = SAR_CD_062_Add2;
      }
   }

   /* Sum: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Add
      1 */
   SAR_CD_062_Add1 = SAR_CD_064_Merge_Y + X_SAR_CD_062_Unit_Delay1;

   /* Sum: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Add
    */
   SAR_CD_062_Add = var_AR_CD_ActvnMgr_ActvnGain.EarActvnUnfild - SAR_CD_062_Add1;

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      ZFDivA_fabs4/Switch
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/ZFDivA_f
      abs4/Switch: Omitted comparison with constant.
      # combined # Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/ZFDivA_fabs4/Relational Operator */
   if (SAR_CD_062_Add < 0.F) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs4/Switch
         # combined # Gain: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
         Mgr_ActvnGain/ZFDivA_fabs4/Gain */
      SAR_CD_068_Switch = SAR_CD_062_Add * -1.F;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/ZFDivA_fabs4/Switch */
      SAR_CD_068_Switch = SAR_CD_062_Add;
   }

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnG
      ain/Relational Operator9 */
   SAR_CD_062_Relational_Operator9 = ((float32) var_AR_CD_ActvnMgr_ActvnGain.EarUnredAcv) ==
    ONE_CONST;

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnG
      ain/Relational Operator8 */
   SAR_CD_062_Relational_Operator8 = ((float32) X_SAR_CD_062_Unit_Delay2) == ZERO_CONST;

   /* Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnG
      ain/Unit Delay2 */
   X_SAR_CD_062_Unit_Delay2 = (sint16) var_AR_CD_ActvnMgr_ActvnGain.EarUnredAcv;

   /* Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain
      /Logical Operator5
      # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/Unit Delay3
      # combined # Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
      Mgr_ActvnGain/Logical Operator4
      # combined # Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/Relational Operator10
      # combined # Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
      Mgr_ActvnGain/Logical Operator7
      # combined # Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Actvn
      Mgr_ActvnGain/Logical Operator3 */
   X_SAR_CD_062_Unit_Delay3 = (SAR_CD_068_Switch >= Rte_CData_EAR_ACTVN_MAX_DIFF()) &&
    ((SAR_CD_062_Relational_Operator9 && SAR_CD_062_Relational_Operator8) ||
    ((!(SAR_CD_062_Relational_Operator9)) && (!(SAR_CD_062_Relational_Operator8))) ||
    X_SAR_CD_062_Unit_Delay3);

   /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/
      Switch2
      AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGain/Switch2:
       Omitted comparison with constant.
      # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/Unit Delay3 */
   if (X_SAR_CD_062_Unit_Delay3) {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/Switch2
         # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD
         _ActvnMgr_ActvnGain/Unit Delay1 */
      X_SAR_CD_062_Unit_Delay1 = SAR_CD_062_Add1;
   }
   else {
      /* Switch: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_ActvnMgr_ActvnGa
         in/Switch2
         # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD
         _ActvnMgr_ActvnGain/Unit Delay1 */
      X_SAR_CD_062_Unit_Delay1 = var_AR_CD_ActvnMgr_ActvnGain.EarActvnUnfild;
   }

   /* # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD_Ac
      tvnMgr_ActvnGain/Unit Delay1 */
   if (EarActvnUnfild < X_SAR_CD_062_Unit_Delay1) {
      var_AR_CD_ActvnMgr_ActvnGain.EarActvn = EarActvnUnfild;
   }
   else {
      /* # combined # Unit delay: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_ActvnGain_tl/AR_CD
         _ActvnMgr_ActvnGain/Unit Delay1 */
      var_AR_CD_ActvnMgr_ActvnGain.EarActvn = X_SAR_CD_062_Unit_Delay1;
   }
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      AR_CD_ActvnMgr_InpSigVer
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      tQualityFactor     RackAbsPosnQF       
 ***      tQualityFactor     RackVQF             
 ***      tQualityFactor     FildVehSpdQF        
 ***      tQualityFactor     ColTqQF             
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
void AR_CD_ActvnMgr_InpSigVer(tQualityFactor RackAbsPosnQF, tQualityFactor RackVQF, tQualityFactor
  FildVehSpdQF, tQualityFactor ColTqQF)
{
   /* Begin execution of chart AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_Ac
      tvnMgr_InpSigVer/RackAbsPosn Check */
   if (Rte_CData_EAR_RACK_ABS_POSN_QF_THD() == QF_UNINITIALISED) {
      /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_
         tl/RackAbsPosnQFSts */
      var_AR_CD_ActvnMgr_InpSigVer.RackAbsPosnQfSts = 1;
   }
   else {
      if (Rte_CData_EAR_RACK_ABS_POSN_QF_THD() == QF_UNAVAILABLE) {
         /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigV
            er_tl/RackAbsPosnQFSts
            # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_C
            D_ActvnMgr_InpSigVer_tl/RackAbsPosnQF
            # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_C
            D_ActvnMgr_InpSigVer_tl/RackAbsPosnQF
            # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_C
            D_ActvnMgr_InpSigVer_tl/RackAbsPosnQF */
         var_AR_CD_ActvnMgr_InpSigVer.RackAbsPosnQfSts = (RackAbsPosnQF == QF_FULL) ||
          (RackAbsPosnQF == QF_DEGRADED) || (RackAbsPosnQF == QF_UNAVAILABLE);
      }
      else {
         if (Rte_CData_EAR_RACK_ABS_POSN_QF_THD() == QF_DEGRADED) {
            /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpS
               igVer_tl/RackAbsPosnQFSts
               # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/A
               R_CD_ActvnMgr_InpSigVer_tl/RackAbsPosnQF
               # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/A
               R_CD_ActvnMgr_InpSigVer_tl/RackAbsPosnQF */
            var_AR_CD_ActvnMgr_InpSigVer.RackAbsPosnQfSts = (RackAbsPosnQF == QF_FULL) ||
             (RackAbsPosnQF == QF_DEGRADED);
         }
         else {
            if (Rte_CData_EAR_RACK_ABS_POSN_QF_THD() == QF_FULL) {
               /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_I
                  npSigVer_tl/RackAbsPosnQFSts
                  # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMg
                  r/AR_CD_ActvnMgr_InpSigVer_tl/RackAbsPosnQF */
               var_AR_CD_ActvnMgr_InpSigVer.RackAbsPosnQfSts = RackAbsPosnQF == QF_FULL;
            }
         }
      }
   }

   /* End execution of chart AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_Actv
      nMgr_InpSigVer/RackAbsPosn Check */

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_ActvnMgr_InpSig
      Ver/Relational Operator5 */
   var_AR_CD_ActvnMgr_InpSigVer.RackVQfSts = QF_FULL == RackVQF;

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_ActvnMgr_InpSig
      Ver/Relational Operator1 */
   var_AR_CD_ActvnMgr_InpSigVer.FildVehSpdQfSts = QF_FULL == FildVehSpdQF;

   /* Relational: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_ActvnMgr_InpSig
      Ver/Relational Operator2 */
   var_AR_CD_ActvnMgr_InpSigVer.ColTqQfSts = QF_FULL == ColTqQF;

   /* Logical: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/AR_CD_ActvnMgr_InpSigVer
      /and Operator
      # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_InpSigVer_tl/
      RackAbsPosnQFSts */
   var_AR_CD_ActvnMgr_InpSigVer.EarInpSigVer = (var_AR_CD_ActvnMgr_InpSigVer.RackAbsPosnQfSts) &&
    (var_AR_CD_ActvnMgr_InpSigVer.RackVQfSts) && (var_AR_CD_ActvnMgr_InpSigVer.FildVehSpdQfSts) &&
    (var_AR_CD_ActvnMgr_InpSigVer.ColTqQfSts);
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      AR_CD_ActvnMgr_RampFac
 *** 
 ***  DESCRIPTION:
 ***      
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      tArbitrationState  ARBArGatewySt       
 ***      Boolean            EarInpSigVer        
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
void AR_CD_ActvnMgr_RampFac(tArbitrationState ARBArGatewySt, Boolean EarInpSigVer)
{
   /* Begin execution of chart AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_Actv
      nMgr_RampFac/rampingwadStateMachine */
   if (CAR_CD_081_EarDisabled) {
      /* Begin execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_A
         ctvnMgr_RampFac/rampingwadStateMachine.EarDisabled */

      /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_A
         ctvnMgr_RampFac_tl/EarInpSigVer
         # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_A
         ctvnMgr_RampFac_tl/EarARBArbnSt */
      if ((EarInpSigVer == TRUE) && (ARBArGatewySt == ARB_READY) && (CAR_CD_081_ear_delay_count >=
       2)) {
         /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_A
            ctvnMgr_RampFac/rampingwadStateMachine.EarDisabled to AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/A
            R_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarWaitingForArbi
            tration */
         CAR_CD_081_EarDisabled = 0;

         /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac
            _tl/EarWaitingForArbitration */
         var_AR_CD_ActvnMgr_RampFac.EarWaitingForArbitration = 1;
         CAR_CD_081_EarARBActvnReq = ARB_REQ_ACT != 0;
      }
      else {
         CAR_CD_081_ear_delay_count = (sint16) (CAR_CD_081_ear_delay_count + ((sint16) 1));
      }

      /* End execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_Act
         vnMgr_RampFac/rampingwadStateMachine.EarDisabled */
   }
   else {
      /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl
         /EarWaitingForArbitration */
      if (var_AR_CD_ActvnMgr_RampFac.EarWaitingForArbitration) {
         /* Begin execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_C
            D_ActvnMgr_RampFac/rampingwadStateMachine.EarWaitingForArbitration */

         /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_C
            D_ActvnMgr_RampFac_tl/EarInpSigVer
            # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_C
            D_ActvnMgr_RampFac_tl/EarARBArbnSt */
         if ((EarInpSigVer == TRUE) && (ARBArGatewySt == ARB_ACTIVE)) {
            /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_C
               D_ActvnMgr_RampFac/rampingwadStateMachine.EarWaitingForArbitration to AR_CD_ActvnMgr_
               tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMac
               hine.EarRampUp */

            /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Ramp
               Fac_tl/EarWaitingForArbitration */
            var_AR_CD_ActvnMgr_RampFac.EarWaitingForArbitration = 0;

            /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Ramp
               Fac_tl/EarRampUp */
            var_AR_CD_ActvnMgr_RampFac.EarRampUp = 1;
         }
         else {
            /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/A
               R_CD_ActvnMgr_RampFac_tl/EarInpSigVer
               # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/A
               R_CD_ActvnMgr_RampFac_tl/EarARBArbnSt */
            if ((EarInpSigVer == FALSE) || (ARBArGatewySt == ARB_LOCKED)) {
               /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/A
                  R_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarWaitingForArbitration to AR_CD_Act
                  vnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampingwa
                  dStateMachine.EarDisabled */

               /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_R
                  ampFac_tl/EarWaitingForArbitration */
               var_AR_CD_ActvnMgr_RampFac.EarWaitingForArbitration = 0;
               CAR_CD_082_EarDisabled_en();
            }
         }

         /* End execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_
            ActvnMgr_RampFac/rampingwadStateMachine.EarWaitingForArbitration */
      }
      else {
         /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac
            _tl/EarRampDown */
         if (var_AR_CD_ActvnMgr_RampFac.EarRampDown) {
            /* Begin execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/A
               R_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampDown */
            if (CAR_CD_081_ear_ramp_fac_unlim <= 0.F) {
               /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/A
                  R_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampDown to AR_CD_ActvnMgr_tl/AR_C
                  D_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine
                  .EarDisabled */

               /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_R
                  ampFac_tl/EarRampDown */
               var_AR_CD_ActvnMgr_RampFac.EarRampDown = 0;
               CAR_CD_082_EarDisabled_en();
            }
            else {
               CAR_CD_081_ear_ramp_fac_unlim = CAR_CD_081_ear_ramp_fac_unlim - (0.001F *
                Rte_CData_EAR_RAMP_DOWN_RATE());
            }

            /* End execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_
               CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampDown */
         }
         else {
            /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_Ramp
               Fac_tl/EarRampUp */
            if (var_AR_CD_ActvnMgr_RampFac.EarRampUp) {
               /* Begin execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_t
                  l/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampUp */

               /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMg
                  r/AR_CD_ActvnMgr_RampFac_tl/EarInpSigVer
                  # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_ActvnMg
                  r/AR_CD_ActvnMgr_RampFac_tl/EarARBArbnSt */
               if ((EarInpSigVer == TRUE) && (ARBArGatewySt == ARB_ACTIVE) &&
                (CAR_CD_081_ear_ramp_fac_unlim >= 1.F)) {
                  /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_t
                     l/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampUp to AR_CD_ActvnMgr_tl/
                     AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampingwadState
                     Machine.EarEnabled */

                  /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMg
                     r_RampFac_tl/EarRampUp */
                  var_AR_CD_ActvnMgr_RampFac.EarRampUp = 0;

                  /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMg
                     r_RampFac_tl/EarEnabled */
                  var_AR_CD_ActvnMgr_RampFac.EarEnabled = 1;
                  CAR_CD_081_ear_ramp_fac_unlim = 1.F;
               }
               else {
                  /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_Actv
                     nMgr/AR_CD_ActvnMgr_RampFac_tl/EarInpSigVer
                     # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_Actv
                     nMgr/AR_CD_ActvnMgr_RampFac_tl/EarARBArbnSt */
                  if ((EarInpSigVer == FALSE) || (ARBArGatewySt != ARB_ACTIVE)) {
                     /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
                        c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampUp to AR_CD_ActvnM
                        gr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampin
                        gwadStateMachine.EarRampDown */

                     /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_Actv
                        nMgr_RampFac_tl/EarRampUp */
                     var_AR_CD_ActvnMgr_RampFac.EarRampUp = 0;

                     /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_Actv
                        nMgr_RampFac_tl/EarRampDown */
                     var_AR_CD_ActvnMgr_RampFac.EarRampDown = 1;
                  }
                  else {
                     CAR_CD_081_ear_ramp_fac_unlim = CAR_CD_081_ear_ramp_fac_unlim + (0.001F *
                      Rte_CData_EAR_RAMP_UP_RATE());
                  }
               }

               /* End execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/
                  AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarRampUp */
            }
            else {
               /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_R
                  ampFac_tl/EarEnabled */
               if (var_AR_CD_ActvnMgr_RampFac.EarEnabled) {
                  /* Begin execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
                     c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarEnabled */

                  /* # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_Actv
                     nMgr/AR_CD_ActvnMgr_RampFac_tl/EarInpSigVer
                     # combined # update of variable(s) associated with AR_CD_ActvnMgr_tl/AR_CD_Actv
                     nMgr/AR_CD_ActvnMgr_RampFac_tl/EarARBArbnSt */
                  if ((EarInpSigVer == FALSE) || (ARBArGatewySt != ARB_ACTIVE)) {
                     /* State transition from AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFa
                        c_tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarEnabled to AR_CD_Actvn
                        Mgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/rampi
                        ngwadStateMachine.EarRampDown */

                     /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_Actv
                        nMgr_RampFac_tl/EarEnabled */
                     var_AR_CD_ActvnMgr_RampFac.EarEnabled = 0;

                     /* # combined # TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_Actv
                        nMgr_RampFac_tl/EarRampDown */
                     var_AR_CD_ActvnMgr_RampFac.EarRampDown = 1;
                  }

                  /* End execution of state AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_
                     tl/AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarEnabled */
               }
               else {
                  /* State transition to AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/
                     AR_CD_ActvnMgr_RampFac/rampingwadStateMachine.EarDisabled */
                  CAR_CD_082_EarDisabled_en();
               }
            }
         }
      }
   }

   /* End execution of chart AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnM
      gr_RampFac/rampingwadStateMachine */

   /* TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/EarDisabled */
   var_AR_CD_ActvnMgr_RampFac.EarDisabled = CAR_CD_081_EarDisabled;

   /* TargetLink outport: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/EarARBActvnReq
    */
   var_AR_CD_ActvnMgr.EarARBActvnReq = CAR_CD_081_EarARBActvnReq;

   /* Saturation: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_ActvnMgr_RampFac/
      Ear Ramp Fac Limd */
   if (CAR_CD_081_ear_ramp_fac_unlim > 1.F) {
      var_AR_CD_ActvnMgr.EarRampFac = 1.F;
   }
   else {
      if (CAR_CD_081_ear_ramp_fac_unlim < 0.F) {
         var_AR_CD_ActvnMgr.EarRampFac = 0.F;
      }
      else {
         var_AR_CD_ActvnMgr.EarRampFac = CAR_CD_081_ear_ramp_fac_unlim;
      }
   }
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      Tab1DnMS3I2T3126_AR_CD_04
 *** 
 ***  DESCRIPTION:
 ***      Generated function for look-up tables.
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      uint8              Nx                  number of axis points
 ***      const float32 *    x_table             vector with x-values
 ***      const float32 *    z_table             vector with z-values
 ***      float32            x                   table input
 ***
 ***  RETURNS:
 ***      float32
 ***
 ***  SETTINGS:
 ***      Search algorithm...................: binary search
 ***      Look-up method.....................: Interpolation - Use end values
 ***      Distances fit into given bitlengths: no
 ***      Behavior at boundaries.............: no
 ***      Starting point.....................: - (non-equidistant implementation)
 ***      Scaling unit.......................: - (non-equidistant implementation)
 ***
\**************************************************************************************************/
float32 Tab1DnMS3I2T3126_AR_CD_04(uint8 Nx, const float32 * x_table, const float32 * z_table,
  float32 x)
{
   /* SLLocal: Default storage class for local variables | Width: 8 */
   uint8 Aux_U8;
   uint8 Aux_U8_a;
   uint8 Aux_U8_b;

   if (x <= *x_table) {
      /* Saturation. */
      return z_table[0];
   }
   if (x >= x_table[(uint8) (Nx - ((uint8) 1))]) {
      return z_table[(uint8) (Nx - ((uint8) 1))];
   }
   Aux_U8 = 0;

   /* Binary search. */
   Aux_U8_a = (uint8) (Nx - ((uint8) 1));
   do {
      Aux_U8_b = (uint8) (uint16) (((uint16) (((uint16) Aux_U8) + ((uint16) Aux_U8_a))) >> 1);
      if (x < x_table[Aux_U8_b]) {
         Aux_U8_a = Aux_U8_b;
      }
      else {
         Aux_U8 = Aux_U8_b;
      }
   }
   while (((sint16) Aux_U8) < ((sint16) (((sint16) Aux_U8_a) - ((sint16) 1))));
   x_table += Aux_U8;
   z_table += Aux_U8;

   /* Interpolation. */
   return (z_table[0] + (((z_table[1] - z_table[0]) * (x - x_table[0])) / (x_table[1] -
    x_table[0])));
}

/*----------------------------------------------------------------------------*\
  MODULE LOCAL FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      CAR_CD_082_EarDisabled_en
 *** 
 ***  DESCRIPTION:
 ***      Entry function of state: AR_CD_ActvnMgr_tl/AR_CD_ActvnMgr/AR_CD_ActvnMgr_RampFac_tl/AR_CD_
 ***      ActvnMgr_RampFac/rampingwadStateMachine.EarDisabled
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***
\**************************************************************************************************/
static void CAR_CD_082_EarDisabled_en(void)
{
   CAR_CD_081_EarDisabled = 1;
   CAR_CD_081_ear_ramp_fac_unlim = 0.F;
   CAR_CD_081_EarARBActvnReq = ARB_PASSIVE != 0;
   CAR_CD_081_ear_delay_count = 1;
}

#endif /* AR_CD_ACTVNMGR_C */
/*----------------------------------------------------------------------------*\
  END OF FILE
\*----------------------------------------------------------------------------*/
